// Timer realization
// (c) jimon game studio

#ifndef JEH_CTIMER
#define JEH_CTIMER

#include "ITimer.h"
#include "jeThreads.h"

#ifdef JE_WIN
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif

#ifdef JE_LINUX
#include <sys/time.h>
#endif

namespace je
{
	namespace core
	{
		//! Timer realization
		class CTimer:public je::core::ITimer
		{
		private:
			#ifdef JE_WIN
			u1 FirstRun;
			f64 Frequency;
			f64 Freq;
			LARGE_INTEGER basefrequency;
			LARGE_INTEGER Started;
			f64 LastValue;
			LARGE_INTEGER perfTime;
			#endif

			#ifdef JE_LINUX
			u1 FirstRun;
			struct timeval TimeStart, TimeEnd;
			struct timezone TimeZone;
			#endif

			f64 Correction;
		public:
			//! Construct
			CTimer();

			//! Destruct
			~CTimer();

			//! Get current programm time
			f64 GetTime();

			//! If we need to correct return time, +1 add 1 millisec to return time, -1 sub one millisec
			void SetTimeCorrection(f64 Correction);
		};
	}
}

#endif
